using ASP;
using HoWave.Common;
using HoWave.Data.Bll;
using HoWave.Data.Model;
using HoWave.Web;
using HoWave.Web.DataHelper;
using HoWave.Web.Shop;
using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.IO;
using System.Linq;
using System.Web;
using System.Web.Profile;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
public class Add_Products : Shop, IRequiresSessionState
{
	protected HtmlHead Head1;
	protected ScriptManager ScriptManager1;
	protected UserControls_cmpy_Top Top1;
	protected Literal ltrProClass;
	protected RadioButton rdoProductType1;
	protected RadioButton rdoProductType2;
	protected RadioButton rdoProductType3;
	protected RadioButton rdoProductType4;
	protected RadioButton rdoProductType5;
	protected HtmlGenericControl productType_Edit_1;
	protected Literal ltrProductType;
	protected HiddenField HiddenFieldProductType;
	protected HiddenField HiddenFieldProductID;
	protected HiddenField HiddenFieldImgID;
	protected HtmlGenericControl productType_Edit_2;
	protected RadioButton rdoProductStandard1;
	protected RadioButton rdoProductStandard2;
	protected HtmlInputText goods_name;
	protected HtmlInputText goods_lbl1;
	protected HtmlInputText goods_lbl2;
	protected HtmlInputText goods_lbl3;
	protected HtmlInputText goods_lbl4;
	protected HtmlInputText goods_store_price;
	protected HtmlInputText CustomPrice;
	protected HtmlInputText txtImcrementPrice;
	protected HtmlInputText txtAuctionStartPrice;
	protected DropDownList DropTeamNum;
	protected Literal TeamName1;
	protected HtmlInputText TeamNumber1;
	protected HtmlInputText TeamPrice1;
	protected Literal TeamName2;
	protected HtmlInputText TeamNumber2;
	protected HtmlInputText TeamPrice2;
	protected Literal TeamName3;
	protected HtmlInputText TeamNumber3;
	protected HtmlInputText TeamPrice3;
	protected Literal TeamName4;
	protected HtmlInputText TeamNumber4;
	protected HtmlInputText TeamPrice4;
	protected Literal TeamName5;
	protected HtmlInputText TeamNumber5;
	protected HtmlInputText TeamPrice5;
	protected HtmlInputText OrderMoneyPercent;
	protected HtmlInputText txtPromotePrice;
	protected HtmlInputText BeginTimeDay;
	protected DropDownList ddlBeginTimeHour;
	protected DropDownList ddlBeginTimeMM;
	protected HtmlInputText EndTimeDay;
	protected DropDownList ddlEndTimeHour;
	protected DropDownList ddlEndTimeMM;
	protected HtmlInputText txtNeedPresentExp;
	protected HtmlInputText goods_storage;
	protected HtmlInputText txtAlarmNum;
	protected DropDownList ddlCalculateUnit;
	protected HtmlInputText goods_serial;
	protected HtmlImage img1;
	protected FileUpload FileUpload1;
	protected HiddenField HiddenField1;
	protected HtmlImage img2;
	protected FileUpload FileUpload2;
	protected HiddenField HiddenField2;
	protected HtmlImage img3;
	protected FileUpload FileUpload3;
	protected HiddenField HiddenField3;
	protected HtmlImage img4;
	protected FileUpload FileUpload4;
	protected HiddenField HiddenField4;
	protected HtmlImage img5;
	protected FileUpload FileUpload5;
	protected HiddenField HiddenField5;
	protected HtmlImage img6;
	protected FileUpload FilePic;
	protected HiddenField HiddenField6;
	protected Panel AttributesPanel;
	protected HtmlGenericControl AttributesDiv;
	protected UpdatePanel upAttribute;
	protected HtmlGenericControl spec_group_dl_1;
	protected HtmlInputText txtBrand;
	protected TextBox TxtDesc;
	protected DropDownList ddlProvince;
	protected DropDownList ddlCity;
	protected DropDownList ddlArea;
	protected RadioButton whops_seller;
	protected RadioButton whops_buyer;
	protected RadioButton isApplyPostage_true;
	protected RadioButtonList CheckBoxList_DeliverType;
	protected Label deliverText;
	protected Button Button_refresh;
	protected UpdatePanel UpdatePanel2;
	protected DropDownList DDLClass;
	protected DropDownList ValidDay;
	protected RadioButton rdo_lj;
	protected RadioButton rdo_fb;
	protected HtmlInputText starttime;
	protected DropDownList ddlStattime;
	protected DropDownList ddlStattime_minute;
	protected RadioButton rdo_ck;
	protected RadioButton rdo_commend;
	protected RadioButton rdo_none;
	protected HtmlInputText seo_keywords;
	protected HtmlTextArea seo_description;
	protected HiddenField HiddenFieldTitle;
	protected HiddenField HiddenFieldValue;
	protected Button btnSubmit2;
	protected HiddenField HFTitle;
	protected HiddenField HFValue;
	protected HiddenField HFValueDetail;
	protected UserControls_CMYP_Foot Foot1;
	protected HtmlForm form1;
	private string proType = "";
	private int _Class_id = -1;
	private int t_class_id = -1;
	private CM_ProductsBll _products;
	private Shop_Class _class;
	private Shop_City _city;
	private string stamp;
	private int attributesClassID = -1;
	private int _ProductID = 0;
	private Dictionary<string, string> _dict = null;
	private string spValues = "";
	private string spValueDetail = "";
	protected DefaultProfile Profile
	{
		get
		{
			return (DefaultProfile)this.Context.Profile;
		}
	}
	protected global_asax ApplicationInstance
	{
		get
		{
			return (global_asax)this.Context.ApplicationInstance;
		}
	}
	public string ProType
	{
		get
		{
			this.proType = base.ShowProType;
			return this.proType;
		}
	}
	public int Class_id
	{
		get
		{
			string text = base.Request.QueryString["class_id"];
			int class_id;
			if (!string.IsNullOrEmpty(text))
			{
				this._Class_id = text.ToInt32(new int[0]);
				class_id = this._Class_id;
			}
			else
			{
				class_id = this._Class_id;
			}
			return class_id;
		}
		set
		{
			this._Class_id = value;
		}
	}
	public int T_class_id
	{
		get
		{
			string text = base.Request.QueryString["t_classid"];
			int result;
			if (!string.IsNullOrEmpty(text))
			{
				this.t_class_id = text.ToInt32(new int[0]);
				result = this.t_class_id;
			}
			else
			{
				result = this.t_class_id;
			}
			return result;
		}
		set
		{
			this.t_class_id = value;
		}
	}
	public CM_ProductsBll Products
	{
		get
		{
			CM_ProductsBll products;
			if (this._products == null)
			{
				this._products = new CM_ProductsBll();
				products = this._products;
			}
			else
			{
				products = this._products;
			}
			return products;
		}
		set
		{
			this._products = value;
		}
	}
	public Shop_Class shopClass
	{
		get
		{
			Shop_Class @class;
			if (this._class == null)
			{
				this._class = new Shop_Class();
				@class = this._class;
			}
			else
			{
				@class = this._class;
			}
			return @class;
		}
		set
		{
			this._class = value;
		}
	}
	public Shop_City cm_city
	{
		get
		{
			if (this._city == null)
			{
				this._city = new Shop_City();
			}
			return this._city;
		}
		set
		{
			this._city = value;
		}
	}
	public string Stamp
	{
		get
		{
			try
			{
				string obj = base.Request.QueryString["ProductID"].ToString();
				this.ProductID = obj.ToInt32(new int[0]);
				this.stamp = "edit";
			}
			catch (Exception)
			{
				this.stamp = "add";
				this.dict["season"] = "0";
				int num = 0;
				this.dict["style"] = num.ToString();
				this.dict["material"] = "0";
				this.dict["type"] = "0";
			}
			return this.stamp;
		}
		set
		{
			this.stamp = value;
		}
	}
	public string ClassID_edit
	{
		get
		{
			return (string)this.ViewState["classiD"];
		}
		set
		{
			this.ViewState["classiD"] = value;
		}
	}
	public int AttributesClassID
	{
		get
		{
			if (this.Stamp == "add")
			{
				string text = this.T_class_id.ToString();
				if (!string.IsNullOrEmpty(text))
				{
					this.attributesClassID = text.ToInt32(new int[0]);
				}
			}
			else
			{
				this.attributesClassID = this.ClassID_edit.ToInt32(new int[0]);
			}
			while (this.attributesClassID > 0)
			{
				string sql = "select ClassID,ParentID,Attributes_Type from HLShop_Class where ClassID=" + this.attributesClassID;
				DataTable dataTable = this.conn.GetDataTable(sql);
				if (dataTable.Rows.Count > 0)
				{
					if (dataTable.Rows[0]["Attributes_Type"] != DBNull.Value)
					{
						string a = dataTable.Rows[0]["Attributes_Type"].ToString();
						if (!(a == "-1"))
						{
							this.attributesClassID = dataTable.Rows[0]["ClassID"].ToInt32(new int[0]);
							break;
						}
						this.attributesClassID = dataTable.Rows[0]["ParentID"].ToInt32(new int[0]);
					}
					else
					{
						this.attributesClassID = dataTable.Rows[0]["ParentID"].ToInt32(new int[0]);
					}
				}
			}
			return this.attributesClassID;
		}
		set
		{
			this.attributesClassID = value;
		}
	}
	protected int ProductID
	{
		get
		{
			return this._ProductID;
		}
		set
		{
			this._ProductID = value;
		}
	}
	protected Dictionary<string, string> dict
	{
		get
		{
			if (this._dict == null)
			{
				this._dict = new Dictionary<string, string>();
			}
			return this._dict;
		}
		set
		{
			this._dict = value;
		}
	}
	public string SpValues
	{
		get
		{
			return this.spValues;
		}
		set
		{
			this.spValues = value;
		}
	}
	public string SpValueDetail
	{
		get
		{
			return this.spValueDetail;
		}
		set
		{
			this.spValueDetail = value;
		}
	}
	protected string strcity
	{
		get;
		set;
	}
	protected string strarea
	{
		get;
		set;
	}
	protected void Page_Load(object sender, EventArgs e)
	{
		if (base.user.UserID < 1)
		{
			base.Response.Redirect("Passport/Login.aspx");
		}
		else
		{
			if (!this.OpenShop(base.user.UserID))
			{
				this.WriteErrMsg("", Language.Get("Member/Common/NoShop"), "/Member/Shop_OpenShop.aspx");
			}
			else
			{
				Shop_Shop shop_Shop = new Shop_Shop(this.conn);
				DataTable shopByShopID = shop_Shop.GetShopByShopID(base.user.ShopID);
				if (shopByShopID.Rows.Count > 0)
				{
					if (shopByShopID.Columns.Contains("ShopStatus"))
					{
						if (shopByShopID.Rows[0]["ShopStatus"] != DBNull.Value)
						{
							string text = shopByShopID.Rows[0]["ShopStatus"].ToString();
							if (text.Trim() == "-1")
							{
								this.WriteErrMsg("", Language.Get("Shop/ShopStatus/Close"), "/Member/MyShop.aspx");
								return;
							}
						}
					}
				}
				if (!base.IsPostBack)
				{
					this.ViewState["HtmlTable"] = 0;
					if (!string.IsNullOrEmpty(this.ProType))
					{
						this.rdoProductType5.Visible = false;
						string text2 = this.ProType;
						if (text2 != null)
						{
							if (!(text2 == "4"))
							{
								if (text2 == "5")
								{
									this.rdoProductType5.Visible = true;
									this.rdoProductType5.Checked = true;
								}
							}
							else
							{
								this.rdoProductType4.Visible = true;
								this.rdoProductType4.Checked = true;
							}
						}
					}
					DataTable dataTable = BLLInstance.BllCalculateUnit.GetList("").Tables[0];
					if (dataTable.Rows.Count > 0)
					{
						foreach (DataRow dr in dataTable.Rows)
						{
							string dataRow = dr.GetDataRow("CalculateUnitName");
							this.ddlCalculateUnit.Items.Add(new ListItem(dataRow, dataRow));
						}
					}
					this.ddlCalculateUnit.Items.Insert(0, new ListItem("请选择", ""));
					this.Template();
					this.GetFileUpload();
					this.BindDeliverType();
					if (this.Stamp == "add")
					{
						if (StaticFun.IsNeedCheckIdentifyRegCode && !Certify.CheckIdentifyRegCode())
						{
							int num = Conn.GetSingle("select count(1) from HLShop_Product", new IDbDataParameter[0]).ToInt32(new int[0]);
							if (num >= 100)
							{
								this.Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "alert", "<script>alert('您的程序未通过官方验证，最多只能发布100件商品，商业版无限制！');location.href='index.aspx';</script>", false);
							}
						}
						else
						{
							this.goods_serial.Value = DateTime.Now.TimeString();
							this.GetBindAttribute(this.AttributesClassID);
						}
					}
					else
					{
						int iD = Fetch.GetID("ProductID");
						DataTable productByProductID = this.Products.GetProductByProductID(iD);
						this.HiddenFieldProductID.Value = iD.ToString();
						this.productType_Edit_1.Visible = false;
						this.productType_Edit_2.Visible = true;
						this.CustomPrice.Value = productByProductID.Rows[0]["CustomPrice"].IsNull(new object[0]);
						this.ddlCalculateUnit.ddlSelect(productByProductID.Rows[0]["PUnit"].IsNull(new object[0]));
						this.HiddenFieldProductType.Value = productByProductID.Rows[0]["ProductType"].ToString();
						this.InitShowProductType(productByProductID);
						DataTable proClassByClassID = this.Products.GetProClassByClassID(Convert.ToInt32(productByProductID.Rows[0]["ClassID"].ToString()));
						this.ViewState["classiD"] = productByProductID.Rows[0]["ClassID"].ToString();
						if (proClassByClassID != null && proClassByClassID.Rows.Count != 0)
						{
							this.ltrProClass.Text = proClassByClassID.Rows[0]["ClassName"].ToString();
						}
						string text2 = productByProductID.Rows[0]["ProductStandard"].ToString();
						if (text2 != null)
						{
							if (!(text2 == "1"))
							{
								if (text2 == "2")
								{
									this.rdoProductStandard2.Checked = true;
								}
							}
							else
							{
								this.rdoProductStandard1.Checked = true;
							}
						}
						this.goods_name.Value = productByProductID.Rows[0]["ProductName"].ToString();
						string text3 = productByProductID.Rows[0]["Goods_lbl"].ToString();
						if (text3.Contains('、'))
						{
							string[] array = text3.Split(new char[]
							{
								'、'
							});
							for (int i = 1; i <= array.Length; i++)
							{
								((HtmlInputText)this.FindControl("goods_lbl" + i.ToString())).Value = array[i - 1];
							}
						}
						else
						{
							this.goods_lbl1.Value = text3;
						}
						this.goods_storage.Value = productByProductID.Rows[0]["Stocks"].ToString();
						this.goods_serial.Value = productByProductID.Rows[0]["Goods_serial"].ToString();
						this.TxtDesc.Text = productByProductID.Rows[0]["ProductIntro"].ToString();
						this.txtAlarmNum.Value = productByProductID.Rows[0]["AlarmNum"].ToString();
						if (!string.IsNullOrEmpty(productByProductID.Rows[0]["Province"].ToString()) && productByProductID.Rows[0]["Province"].ToString() != "0")
						{
							this.ddlProvince.SelectedValue = productByProductID.Rows[0]["Province"].ToString();
							this.strcity = productByProductID.Rows[0]["City"].IsNull(new object[0]);
							this.strarea = productByProductID.Rows[0]["Area"].IsNull(new object[0]);
						}
						if (productByProductID.Rows[0]["DeliverPayType"].ToString() == "1")
						{
							this.whops_buyer.Checked = true;
							this.CheckBoxList_DeliverType.SelectedValue = productByProductID.Rows[0]["DeliverType"].ToString();
						}
						else
						{
							this.whops_seller.Checked = true;
						}
						this.ValidDay.SelectedValue = productByProductID.Rows[0]["ValidDay"].ToString();
						if (productByProductID.Columns.Contains("EnableSale"))
						{
							if (productByProductID.Rows[0]["EnableSale"] != DBNull.Value)
							{
								string a = productByProductID.Rows[0]["EnableSale"].ToString().Trim().ToLower();
								if (a == "false" || a == "0")
								{
									this.rdo_ck.Checked = true;
								}
							}
						}
						if (productByProductID.Rows[0]["BeginDate"] != DBNull.Value)
						{
							if (productByProductID.Rows[0]["BeginDate"].ToDateTime(new DateTime[0]) > DateTime.Now)
							{
								this.rdo_fb.Checked = true;
								string text4 = productByProductID.Rows[0]["BeginDate"].ToString();
								string[] array2 = text4.Split(new string[]
								{
									" "
								}, StringSplitOptions.RemoveEmptyEntries);
								if (array2.Length > 1)
								{
									this.starttime.Value = array2[0];
									string shifenStr = array2[1];
									this.InitDateTime(shifenStr, this.ddlStattime, this.ddlStattime_minute);
								}
							}
							else
							{
								this.rdo_lj.Checked = true;
							}
						}
						else
						{
							if (productByProductID.Rows[0]["EnableSingleSell"].ToString().Trim().ToLower() == "true")
							{
								this.rdo_ck.Checked = true;
							}
							else
							{
								this.rdo_lj.Checked = true;
							}
						}
						if (productByProductID.Rows[0]["IsElite"].ToString() == "False")
						{
							this.rdo_none.Checked = true;
						}
						else
						{
							this.rdo_commend.Checked = true;
						}
						this.seo_keywords.Value = productByProductID.Rows[0]["Keyword"].ToString();
						this.seo_description.Value = productByProductID.Rows[0]["Description"].ToString();
						DataTable prodcutImageByProductID = this.Products.GetProdcutImageByProductID(iD);
						if (prodcutImageByProductID != null && prodcutImageByProductID.Rows.Count > 0)
						{
							this.HiddenFieldImgID.Value = prodcutImageByProductID.Rows[0]["ImgID"].ToString();
							if (!string.IsNullOrEmpty(prodcutImageByProductID.Rows[0]["ImgPath1"].ToString()))
							{
								this.img1.Src = ((prodcutImageByProductID.Rows[0]["ImgPath1"].ToString()[0] == '/') ? prodcutImageByProductID.Rows[0]["ImgPath1"].ToString().Substring(1) : prodcutImageByProductID.Rows[0]["ImgPath1"].ToString());
								this.HiddenField1.Value = prodcutImageByProductID.Rows[0]["ImgPath1"].ToString();
							}
							if (!string.IsNullOrEmpty(prodcutImageByProductID.Rows[0]["ImgPath2"].ToString()))
							{
								this.img2.Src = ((prodcutImageByProductID.Rows[0]["ImgPath2"].ToString()[0] == '/') ? prodcutImageByProductID.Rows[0]["ImgPath2"].ToString().Substring(1) : prodcutImageByProductID.Rows[0]["ImgPath2"].ToString());
								this.HiddenField2.Value = prodcutImageByProductID.Rows[0]["ImgPath2"].ToString();
							}
							if (!string.IsNullOrEmpty(prodcutImageByProductID.Rows[0]["ImgPath3"].ToString()))
							{
								this.img3.Src = ((prodcutImageByProductID.Rows[0]["ImgPath3"].ToString()[0] == '/') ? prodcutImageByProductID.Rows[0]["ImgPath3"].ToString().Substring(1) : prodcutImageByProductID.Rows[0]["ImgPath3"].ToString());
								this.HiddenField3.Value = prodcutImageByProductID.Rows[0]["ImgPath3"].ToString();
							}
							if (!string.IsNullOrEmpty(prodcutImageByProductID.Rows[0]["ImgPath4"].ToString()))
							{
								this.img4.Src = ((prodcutImageByProductID.Rows[0]["ImgPath4"].ToString()[0] == '/') ? prodcutImageByProductID.Rows[0]["ImgPath4"].ToString().Substring(1) : prodcutImageByProductID.Rows[0]["ImgPath4"].ToString());
								this.HiddenField4.Value = prodcutImageByProductID.Rows[0]["ImgPath4"].ToString();
							}
							if (!string.IsNullOrEmpty(prodcutImageByProductID.Rows[0]["ImgPath5"].ToString()))
							{
								this.img5.Src = ((prodcutImageByProductID.Rows[0]["ImgPath5"].ToString()[0] == '/') ? prodcutImageByProductID.Rows[0]["ImgPath5"].ToString().Substring(1) : prodcutImageByProductID.Rows[0]["ImgPath5"].ToString());
								this.HiddenField5.Value = prodcutImageByProductID.Rows[0]["ImgPath5"].ToString();
							}
							if (!string.IsNullOrEmpty(productByProductID.Rows[0]["ProductImageUrl"].ToString()))
							{
								this.img6.Src = ((productByProductID.Rows[0]["ProductImageUrl"].ToString()[0] == '/') ? productByProductID.Rows[0]["ProductImageUrl"].ToString().Substring(1) : productByProductID.Rows[0]["ProductImageUrl"].ToString());
								this.HiddenField6.Value = productByProductID.Rows[0]["ProductImageUrl"].ToString();
							}
						}
						this.GetBindAttribute(this.AttributesClassID);
						if (!string.IsNullOrEmpty(productByProductID.Rows[0]["Attributes"].ToString()))
						{
							string[] array3 = productByProductID.Rows[0]["Attributes"].ToString().Split(new string[]
							{
								"|"
							}, StringSplitOptions.None);
							Hashtable hashtable = new Hashtable();
							for (int j = 0; j < array3.Length; j++)
							{
								string[] array4 = array3[j].Split(new string[]
								{
									"<strong>",
									"</strong>"
								}, StringSplitOptions.RemoveEmptyEntries);
								if (array4.Length != 0)
								{
									string key = "";
									string value = "";
									for (int k = 0; k < array4.Length; k++)
									{
										if (k == 0)
										{
											key = array4[k];
										}
										if (k == 1)
										{
											value = array4[k];
										}
									}
									hashtable.Add(key, value);
								}
							}
							ArrayList arrayList = new ArrayList(hashtable.Keys);
							int num2 = int.Parse(this.ViewState["HtmlTable"].ToString());
							foreach (string text5 in arrayList)
							{
								for (int i = 0; i < num2; i++)
								{
									if (this.AttributesPanel.FindControl("Label_" + i) != null)
									{
										Label label = (Label)this.AttributesPanel.FindControl("Label_" + i);
										if (label.Text == text5)
										{
											if (this.AttributesPanel.FindControl("TextBox_" + i) != null)
											{
												TextBox textBox = (TextBox)this.AttributesPanel.FindControl("TextBox_" + i);
												textBox.Text = hashtable[text5].ToString();
												break;
											}
											if (this.AttributesPanel.FindControl("DropDownList_" + i) != null)
											{
												DropDownList dropDownList = (DropDownList)this.AttributesPanel.FindControl("DropDownList_" + i);
												for (int l = 0; l < dropDownList.Items.Count; l++)
												{
													if (dropDownList.Items[l].Value != "")
													{
														if (dropDownList.Items[l].Value == hashtable[text5].ToString())
														{
															dropDownList.SelectedValue = dropDownList.Items[l].Value;
														}
													}
												}
												break;
											}
											if (this.AttributesPanel.FindControl("CheckBoxList_" + i) != null)
											{
												CheckBoxList checkBoxList = (CheckBoxList)this.AttributesPanel.FindControl("CheckBoxList_" + i);
												string text6 = hashtable[text5].ToString().Replace(" / ", ",");
												string[] array5 = text6.Split(new char[]
												{
													','
												});
												for (int m = 0; m < array5.Length; m++)
												{
													foreach (ListItem listItem in checkBoxList.Items)
													{
														if (listItem.Value != "")
														{
															if (array5[m].ToString() == listItem.Value)
															{
																listItem.Selected = true;
															}
														}
													}
												}
												break;
											}
										}
									}
								}
							}
						}
						string a2 = "";
						string text7 = "";
						string text8 = "";
						if (productByProductID.Rows[0]["prc_sp_title"] != DBNull.Value)
						{
							a2 = productByProductID.Rows[0]["prc_sp_title"].ToString();
						}
						if (productByProductID.Rows[0]["prc_sp_value"] != DBNull.Value)
						{
							text7 = productByProductID.Rows[0]["prc_sp_value"].ToString();
						}
						if (productByProductID.Rows[0]["prc_sp_valueDetail"] != DBNull.Value)
						{
							text8 = productByProductID.Rows[0]["prc_sp_valueDetail"].ToString();
						}
						if (a2 != "")
						{
							this.SpValues = text7;
							this.SpValueDetail = text8;
						}
					}
				}
				else
				{
					this.GetBindAttribute(this.AttributesClassID);
				}
			}
		}
	}
	private void InitShowProductType(DataTable dt)
	{
		string text = dt.Rows[0]["ProductType"].ToString();
		if (text != null)
		{
			if (!(text == "1"))
			{
				if (!(text == "2"))
				{
					if (!(text == "3"))
					{
						if (!(text == "4"))
						{
							if (text == "5")
							{
								this.ltrProductType.Text = "积分商品";
								this.goods_store_price.Value = dt.Rows[0]["StandPrice"].ToString();
								this.txtNeedPresentExp.Value = dt.Rows[0]["NeedPresentExp"].ToString();
							}
						}
						else
						{
							this.ltrProductType.Text = "促销";
							this.goods_store_price.Value = dt.Rows[0]["CurrentPrice"].ToString();
							this.txtPromotePrice.Value = dt.Rows[0]["StandPrice"].ToString();
							if (dt.Rows[0]["BeginDate"] != DBNull.Value)
							{
								string text2 = dt.Rows[0]["BeginDate"].ToString();
								string[] array = text2.Split(new string[]
								{
									" "
								}, StringSplitOptions.RemoveEmptyEntries);
								if (array.Length > 1)
								{
									this.BeginTimeDay.Value = array[0];
									string shifenStr = array[1];
									this.InitDateTime(shifenStr, this.ddlBeginTimeHour, this.ddlBeginTimeMM);
								}
							}
							if (dt.Rows[0]["EndDate"] != DBNull.Value)
							{
								string text3 = dt.Rows[0]["EndDate"].ToString();
								string[] array2 = text3.Split(new string[]
								{
									" "
								}, StringSplitOptions.RemoveEmptyEntries);
								if (array2.Length > 1)
								{
									this.EndTimeDay.Value = array2[0];
									string shifenStr = array2[1];
									this.InitDateTime(shifenStr, this.ddlEndTimeHour, this.ddlEndTimeMM);
								}
							}
						}
					}
					else
					{
						this.ltrProductType.Text = "团购";
						this.goods_store_price.Value = dt.Rows[0]["StandPrice"].ToString();
						this.DropTeamNum.SelectedValue = dt.Rows[0]["TeamNum"].ToString();
						this.TeamNumber1.Value = dt.Rows[0]["TeamNumber1"].ToString();
						this.TeamNumber2.Value = dt.Rows[0]["TeamNumber2"].ToString();
						this.TeamNumber3.Value = dt.Rows[0]["TeamNumber3"].ToString();
						this.TeamNumber4.Value = dt.Rows[0]["TeamNumber4"].ToString();
						this.TeamNumber5.Value = dt.Rows[0]["TeamNumber5"].ToString();
						this.TeamPrice1.Value = dt.Rows[0]["TeamPrice1"].ToString();
						this.TeamPrice2.Value = dt.Rows[0]["TeamPrice2"].ToString();
						this.TeamPrice3.Value = dt.Rows[0]["TeamPrice3"].ToString();
						this.TeamPrice4.Value = dt.Rows[0]["TeamPrice4"].ToString();
						this.TeamPrice5.Value = dt.Rows[0]["TeamPrice5"].ToString();
						this.OrderMoneyPercent.Value = dt.Rows[0]["TempSubScriptionRate"].ToString();
						string text4 = dt.Rows[0]["TeamName"].ToString();
					}
				}
				else
				{
					this.ltrProductType.Text = "拍卖";
					this.txtImcrementPrice.Value = dt.Rows[0]["ImcrementPrice"].ToString();
					this.goods_store_price.Value = dt.Rows[0]["CurrentPrice"].ToString();
					this.txtAuctionStartPrice.Value = dt.Rows[0]["AuctionStartPrice"].ToString();
				}
			}
			else
			{
				this.ltrProductType.Text = "一口价";
				this.goods_store_price.Value = dt.Rows[0]["StandPrice"].ToString();
			}
		}
	}
	private void InitDateTime(string shifenStr, DropDownList ddlHour, DropDownList ddlMM)
	{
		string[] array = shifenStr.Split(new string[]
		{
			":"
		}, StringSplitOptions.RemoveEmptyEntries);
		if (array.Length > 1)
		{
			string b = array[0];
			string b2 = array[1];
			for (int i = 0; i < ddlHour.Items.Count; i++)
			{
				if (ddlHour.Items[i].Value == b)
				{
					ddlHour.Items[i].Selected = true;
				}
			}
			for (int j = 0; j < ddlMM.Items.Count; j++)
			{
				if (ddlMM.Items[j].Value == b2)
				{
					ddlMM.Items[j].Selected = true;
				}
			}
		}
	}
	public void Template()
	{
		DataTable proClassByClassID = this.Products.GetProClassByClassID(this.T_class_id);
		if (proClassByClassID != null && proClassByClassID.Rows.Count != 0)
		{
			this.ltrProClass.Text = proClassByClassID.Rows[0]["ClassName"].ToString();
		}
		this.DDLClass.DataSource = this.shopClass.GetRootClass();
		this.DDLClass.DataValueField = "ClassID";
		this.DDLClass.DataTextField = "ClassName";
		this.DDLClass.DataBind();
		this.DDLClass.Items.Insert(0, new ListItem("请选择", "0"));
		this.ddlProvince.DataSource = this.cm_city.GetAllProvinceHL_City();
		this.ddlProvince.DataTextField = "Province";
		this.ddlProvince.DataValueField = "Province";
		this.ddlProvince.DataBind();
		this.ddlProvince.Items.Insert(0, new ListItem("请选择", "0"));
		Dictionary<int, int> dictionary = new Dictionary<int, int>();
		for (int i = 0; i < 24; i++)
		{
			if (i < 10)
			{
				i = i;
			}
			dictionary.Add(i, i);
		}
		this.ddlStattime.DataSource = dictionary;
		this.ddlStattime.DataTextField = "value";
		this.ddlStattime.DataValueField = "key";
		this.ddlStattime.DataBind();
		this.ddlBeginTimeHour.DataSource = dictionary;
		this.ddlBeginTimeHour.DataTextField = "value";
		this.ddlBeginTimeHour.DataValueField = "key";
		this.ddlBeginTimeHour.DataBind();
		this.ddlEndTimeHour.DataSource = dictionary;
		this.ddlEndTimeHour.DataTextField = "value";
		this.ddlEndTimeHour.DataValueField = "key";
		this.ddlEndTimeHour.DataBind();
		this.BeginTimeDay.Value = DateTime.Now.ToShortDateString();
		this.EndTimeDay.Value = DateTime.Now.AddDays(1.0).ToShortDateString();
		this.starttime.Value = DateTime.Now.ToShortDateString();
		this.TeamName1.Text = base.shopconfig["Team1Name"].ToString();
		this.TeamName2.Text = base.shopconfig["Team2Name"].ToString();
		this.TeamName3.Text = base.shopconfig["Team3Name"].ToString();
		this.TeamName4.Text = base.shopconfig["Team4Name"].ToString();
		this.TeamName5.Text = base.shopconfig["Team5Name"].ToString();
		int num = base.shopconfig["TeamSet"].ToInt32(new int[0]);
		for (int i = 1; i <= num; i++)
		{
			ListItem item = new ListItem(i.ToString(), i.ToString());
			this.DropTeamNum.Items.Add(item);
		}
		if (base.shopconfig["Showstandprice"].ToString() != "1")
		{
			this.rdoProductType1.Visible = false;
		}
		if (base.shopconfig["ShowAction"].ToString() != "1")
		{
			this.rdoProductType2.Visible = false;
		}
		if (base.shopconfig["ShowTeam"].ToString() != "1")
		{
			this.rdoProductType3.Visible = false;
		}
		if (base.shopconfig["ShowPromote"].ToString() != "1")
		{
			this.rdoProductType4.Visible = false;
		}
		if (base.shopconfig["ShowScore"].ToString() != "1")
		{
			this.rdoProductType5.Visible = false;
		}
		string text = base.shopconfig["SaleDay"].ToString();
		Dictionary<string, string> dictionary2 = new Dictionary<string, string>();
		if (text.Contains("|"))
		{
			string[] array = text.Split(new char[]
			{
				'|'
			});
			for (int i = 0; i < array.Length; i++)
			{
				dictionary2.Add(array[i], array[i]);
			}
		}
		this.ValidDay.Items.Clear();
		this.ValidDay.DataSource = dictionary2;
		this.ValidDay.DataTextField = "value";
		this.ValidDay.DataValueField = "key";
		this.ValidDay.DataBind();
	}
	public bool OpenShop(int UserID)
	{
		Shop_Product shop_Product = new Shop_Product();
		return shop_Product.JustOpenShop(UserID);
	}
	public void GetBindAttribute(int ClassID)
	{
		DataTable dataTable = this.conn.GetDataTable("select * from dbo.HLShop_Class where ClassID=" + ClassID);
		if (dataTable != null && dataTable.Rows.Count != 0)
		{
			if (string.IsNullOrEmpty(dataTable.Rows[0]["Attributes_Type"].ToString()) && dataTable.Rows[0]["Attributes_Type"].ToString() == "-1")
			{
				this.AttributesDiv.Visible = false;
				this.spec_group_dl_1.Visible = false;
				this.ViewState["HtmlTable"] = 0;
			}
			else
			{
				this.AttributesPanel.Controls.Clear();
				Shop_ProductAttributes shop_ProductAttributes = new Shop_ProductAttributes();
				string attributesType = dataTable.Rows[0]["Attributes_Type"].IsNull(new object[0]);
				DataTable attributesNameByAttributesType = shop_ProductAttributes.GetAttributesNameByAttributesType(attributesType);
				if (attributesNameByAttributesType != null && attributesNameByAttributesType.Rows.Count != 0)
				{
					this.spec_group_dl_1.Visible = true;
					this.AttributesDiv.Visible = true;
				}
				HtmlTable htmlTable = new HtmlTable();
				int num = 0;
				foreach (DataRow dataRow in attributesNameByAttributesType.Rows)
				{
					if (dataRow["Attributes_Select"].ToString() != "" || dataRow["Attributes_Select"] != null)
					{
						HtmlTableCell htmlTableCell = new HtmlTableCell();
						HtmlTableCell htmlTableCell2 = new HtmlTableCell();
						HtmlTableCell htmlTableCell3 = new HtmlTableCell();
						HtmlTableRow htmlTableRow = new HtmlTableRow();
						htmlTableCell.Style.Add("width", "80px");
						htmlTableCell.Style.Add("font-weight", "bold");
						htmlTableCell.Style.Add("text-align", "right");
						htmlTableCell2.Style.Add("text-align", "left");
						Label label = new Label();
						label.ID = "Label_" + num;
						HiddenField hiddenField = new HiddenField();
						hiddenField.ID = "HiddenField_" + num;
						TextBox textBox = new TextBox();
						textBox.ID = "TextBox_" + num;
						textBox.Width = 200;
						if (dataRow["Attributes_Methods"].ToString() == "从列表中选择")
						{
							if (dataRow["Attributes_Value"].ToString() != "")
							{
								label.Text = dataRow["Attributes_Name"].ToString() + "：";
								htmlTableCell.Controls.Add(label);
								hiddenField.Value = dataRow["Attributes_Name"].ToString() + "：";
								htmlTableCell3.Controls.Add(hiddenField);
							}
						}
						else
						{
							label.Text = dataRow["Attributes_Name"].ToString() + "：";
							htmlTableCell.Controls.Add(label);
							hiddenField.Value = dataRow["Attributes_Name"].ToString() + "：";
							htmlTableCell3.Controls.Add(hiddenField);
						}
						htmlTableRow.Controls.Add(htmlTableCell);
						htmlTableRow.Controls.Add(htmlTableCell3);
						if (dataRow["Attributes_Select"].ToString() == "唯一属性")
						{
							string text = dataRow["Attributes_Methods"].ToString();
							if (text != null)
							{
								if (!(text == "手工录入"))
								{
									if (!(text == "从列表中选择"))
									{
										if (text == "多行文本框")
										{
											textBox.TextMode = TextBoxMode.MultiLine;
											textBox.Width = 200;
											textBox.Height = 60;
											htmlTableCell2.Controls.Add(textBox);
										}
									}
									else
									{
										DropDownList dropDownList = new DropDownList();
										dropDownList.ID = "DropDownList_" + num;
										if (dataRow["Attributes_Value"].ToString() != "" && dataRow["Attributes_Value"].ToString() != null)
										{
											string text2 = dataRow["Attributes_Value"].ToString().Replace("\r\n", "|");
											string[] array = text2.Split(new char[]
											{
												'|'
											});
											string[] array2 = array;
											for (int i = 0; i < array2.Length; i++)
											{
												string text3 = array2[i];
												ListItem listItem = new ListItem();
												listItem.Text = text3;
												listItem.Value = text3;
												dropDownList.Items.Add(listItem);
											}
										}
										dropDownList.Items.Insert(0, new ListItem("－请选择－", ""));
										htmlTableCell2.Controls.Add(dropDownList);
									}
								}
								else
								{
									htmlTableCell2.Controls.Add(textBox);
								}
							}
							htmlTableRow.Controls.Add(htmlTableCell2);
							htmlTable.Controls.Add(htmlTableRow);
							this.AttributesPanel.Controls.Add(htmlTable);
						}
						else
						{
							if (dataRow["Attributes_Select"].ToString() == "单选属性")
							{
								string text = dataRow["Attributes_Methods"].ToString();
								if (text != null)
								{
									if (!(text == "手工录入"))
									{
										if (!(text == "从列表中选择"))
										{
											if (text == "多行文本框")
											{
												textBox.TextMode = TextBoxMode.MultiLine;
												textBox.Width = 200;
												textBox.Height = 60;
												htmlTableCell2.Controls.Add(textBox);
											}
										}
										else
										{
											DropDownList dropDownList = new DropDownList();
											dropDownList.ID = "DropDownList_" + num;
											if (dataRow["Attributes_Value"].ToString() != "" && dataRow["Attributes_Value"].ToString() != null)
											{
												string text2 = dataRow["Attributes_Value"].ToString().Replace("\r\n", "|");
												string[] array = text2.Split(new char[]
												{
													'|'
												});
												string[] array2 = array;
												for (int i = 0; i < array2.Length; i++)
												{
													string text3 = array2[i];
													ListItem listItem = new ListItem();
													listItem.Text = text3;
													listItem.Value = text3;
													dropDownList.Items.Add(listItem);
												}
											}
											dropDownList.Items.Insert(0, new ListItem("－请选择－", ""));
											htmlTableCell2.Controls.Add(dropDownList);
										}
									}
									else
									{
										htmlTableCell2.Controls.Add(textBox);
									}
								}
								htmlTableRow.Controls.Add(htmlTableCell2);
								htmlTable.Controls.Add(htmlTableRow);
								this.AttributesPanel.Controls.Add(htmlTable);
							}
							else
							{
								if (dataRow["Attributes_Select"].ToString() == "复选属性")
								{
									string text = dataRow["Attributes_Methods"].ToString();
									if (text != null)
									{
										if (!(text == "手工录入"))
										{
											if (!(text == "从列表中选择"))
											{
												if (text == "多行文本框")
												{
													textBox.TextMode = TextBoxMode.MultiLine;
													textBox.Width = 200;
													textBox.Height = 60;
													htmlTableCell2.Controls.Add(textBox);
												}
											}
											else
											{
												CheckBoxList checkBoxList = new CheckBoxList();
												checkBoxList.ID = "CheckBoxList_" + num;
												if (dataRow["Attributes_Value"].ToString() != "" && dataRow["Attributes_Value"].ToString() != null)
												{
													string text2 = dataRow["Attributes_Value"].ToString().Replace("\r\n", "|");
													string[] array = text2.Split(new char[]
													{
														'|'
													});
													string[] array2 = array;
													for (int i = 0; i < array2.Length; i++)
													{
														string text3 = array2[i];
														ListItem listItem = new ListItem();
														listItem.Text = text3;
														listItem.Value = text3;
														checkBoxList.RepeatColumns = 8;
														checkBoxList.RepeatDirection = RepeatDirection.Horizontal;
														checkBoxList.Items.Add(listItem);
													}
												}
												checkBoxList.SelectedIndexChanged += new EventHandler(this.cbl_SelectedIndexChanged);
												checkBoxList.AutoPostBack = true;
												htmlTableCell2.Controls.Add(checkBoxList);
											}
										}
										else
										{
											htmlTableCell2.Controls.Add(textBox);
										}
									}
									htmlTableRow.Controls.Add(htmlTableCell2);
									htmlTable.Controls.Add(htmlTableRow);
									this.AttributesPanel.Controls.Add(htmlTable);
								}
							}
						}
					}
					num++;
				}
				this.ViewState["HtmlTable"] = htmlTable.Controls.Count;
			}
		}
	}
	public void GetFileUpload()
	{
		this.FileUpload1.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FileUpload1.ClientID + "');");
		this.FileUpload2.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FileUpload2.ClientID + "');");
		this.FileUpload3.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FileUpload3.ClientID + "');");
		this.FileUpload4.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FileUpload4.ClientID + "');");
		this.FileUpload5.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FileUpload5.ClientID + "');");
		this.FilePic.Attributes.Add("onchange", "ajaxProductPicUpload('" + this.FilePic.ClientID + "');");
	}
	protected void ddlProvince_Changed(object sender, EventArgs e)
	{
		DataTable cityByProvinceFromHL_CityAreaCity = this.cm_city.GetCityByProvinceFromHL_CityAreaCity(this.ddlProvince.SelectedValue);
		if (cityByProvinceFromHL_CityAreaCity != null && cityByProvinceFromHL_CityAreaCity.Rows.Count != 0)
		{
			this.ddlCity.Visible = true;
			this.ddlCity.DataSource = cityByProvinceFromHL_CityAreaCity;
			this.ddlCity.DataTextField = "City";
			this.ddlCity.DataValueField = "City";
			this.ddlCity.DataBind();
			this.ddlCity.Items.Insert(0, new ListItem("请选择", "0"));
		}
	}
	protected void ddlCity_Changed(object sender, EventArgs e)
	{
		DataTable areaByCityFromHL_CityAreaArea = this.cm_city.GetAreaByCityFromHL_CityAreaArea(this.ddlCity.SelectedValue);
		if (areaByCityFromHL_CityAreaArea != null && areaByCityFromHL_CityAreaArea.Rows.Count != 0)
		{
			this.ddlArea.Visible = true;
			this.ddlArea.DataSource = areaByCityFromHL_CityAreaArea;
			this.ddlArea.DataTextField = "Area";
			this.ddlArea.DataValueField = "Area";
			this.ddlArea.DataBind();
			this.ddlArea.Items.Insert(0, new ListItem("请选择", "0"));
		}
	}
	protected void BindDeliverType()
	{
		Shop_DeliverType shop_DeliverType = new Shop_DeliverType(this.conn);
		DataTable deliverTypeByUserIDTypeIDStatus = shop_DeliverType.GetDeliverTypeByUserIDTypeIDStatus(base.user.UserID, -1, 0);
		if (deliverTypeByUserIDTypeIDStatus.Rows.Count > 0)
		{
			this.CheckBoxList_DeliverType.DataSource = deliverTypeByUserIDTypeIDStatus;
			this.CheckBoxList_DeliverType.DataTextField = "typename";
			this.CheckBoxList_DeliverType.DataValueField = "typeid";
			this.CheckBoxList_DeliverType.DataBind();
			foreach (ListItem listItem in this.CheckBoxList_DeliverType.Items)
			{
				listItem.Selected = true;
			}
		}
		else
		{
			this.deliverText.Text = Language.Get("Shop/Product/NoDeliverType");
		}
	}
	protected void cbl_SelectedIndexChanged(object sender, EventArgs e)
	{
		string text = "";
		string text2 = "";
		string text3 = "";
		int num = int.Parse(this.ViewState["HtmlTable"].ToString());
		for (int i = 0; i < num; i++)
		{
			bool flag = false;
			if (this.AttributesPanel.FindControl("CheckBoxList_" + i) != null)
			{
				string text4 = "";
				string text5 = "";
				HiddenField hiddenField = (HiddenField)this.AttributesPanel.FindControl("HiddenField_" + i);
				CheckBoxList checkBoxList = (CheckBoxList)this.AttributesPanel.FindControl("CheckBoxList_" + i);
				foreach (ListItem listItem in checkBoxList.Items)
				{
					if (listItem.Selected)
					{
						text5 = text5 + listItem.Value + ",";
						text4 = hiddenField.Value;
						flag = true;
					}
				}
				text = text4;
				text2 = text5;
			}
			if (flag)
			{
				if (text != "" && text2 != "")
				{
					if (text2.Length > 0)
					{
						string a = text2.Substring(text2.Length - 1);
						if (a == ",")
						{
							text2 = text2.Substring(0, text2.Length - 1);
						}
					}
					text2 = text2.Replace(",", " / ");
					string text6 = text3;
					text3 = string.Concat(new string[]
					{
						text6,
						"<strong>",
						text,
						"</strong>",
						text2,
						"|"
					});
				}
			}
		}
		this.ViewState["cblChecked"] = text3;
	}
	protected void btnSubmit2_Click(object sender, EventArgs e)
	{
		string value = this.HiddenFieldTitle.Value;
		string value2 = this.HiddenFieldValue.Value;
		ProductModels productModels = new ProductModels();
		productModels.ShopID = base.user.ShopID;
		int userID = base.user.UserID;
		productModels.SalerID = userID;
		productModels.ClassID = this.Class_id;
		int value3 = 0;
		int needPresentExp = 0;
		productModels.ProductName = this.goods_name.Value;
		productModels.ProductIntro = this.TxtDesc.Text;
		productModels.ProductImageUrl = this.HiddenField6.Value;
		productModels.ProductSmallImageUrl = this.HiddenField1.Value;
		if (productModels.ProductImageUrl == "")
		{
			productModels.ProductImageUrl = productModels.ProductSmallImageUrl;
		}
		Watermark watermark = new Watermark();
		string extension = Path.GetExtension(productModels.ProductImageUrl);
		int num = StaticFunApp.SiteConfig["SamllPic_DefaultWidth"].ToInt32(new int[0]);
		int num2 = StaticFunApp.SiteConfig["SamllPic_DefaultHieght"].ToInt32(new int[0]);
		if (num < 10)
		{
			num = 220;
		}
		if (num2 < 10)
		{
			num2 = 220;
		}
		string text = productModels.ProductImageUrl.StartsWith("/") ? productModels.ProductImageUrl : ("/" + productModels.ProductImageUrl);
		text = text.Replace("_small", "");
		string text2 = string.Format("{0}_small{1}", text.TrimEnd(extension.ToArray<char>()), extension);
		string path = HttpContext.Current.Server.MapPath(text2);
		if (File.Exists(path))
		{
			File.Delete(path);
		}
		bool flag = watermark.CreateSmallPic(text, text2, num, num2);
		if (flag)
		{
			productModels.ProductImageUrl = text2.TrimStart(new char[]
			{
				'/'
			});
		}
		productModels.Prc_sp_title = this.HFTitle.Value;
		productModels.Prc_sp_value = this.HFValue.Value;
		productModels.Prc_sp_valueDetail = this.HFValueDetail.Value;
		DateTime dateTime = DateTime.Now;
		productModels.EnableSingleSell = 1;
		productModels.EnableSale = 1;
		if (this.rdo_ck.Checked)
		{
			productModels.EnableSale = 0;
		}
		else
		{
			if (this.rdo_fb.Checked)
			{
				string value4 = this.starttime.Value;
				string text3 = this.ddlStattime.SelectedItem.Text;
				string text4 = this.ddlStattime_minute.SelectedItem.Text;
				dateTime = string.Concat(new string[]
				{
					value4,
					" ",
					text3,
					":",
					text4,
					":00"
				}).ToDateTime(new DateTime[0]);
				if (dateTime < DateTime.Now)
				{
					productModels.EnableSingleSell = 0;
				}
				else
				{
					productModels.EnableSingleSell = 1;
				}
			}
		}
		productModels.ValidDay = this.ValidDay.SelectedItem.Text.ToInt32(new int[0]);
		DateTime endDate = dateTime.AddDays(double.Parse(this.ValidDay.SelectedValue));
		int productType = 1;
		productModels.ImcrementPrice = 0m;
		productModels.CurrentPrice = 0m;
		productModels.StandPrice = 0m;
		productModels.AuctionStartPrice = 0m;
		if (this.rdoProductType1.Checked)
		{
			productType = 1;
			productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
		}
		else
		{
			if (this.rdoProductType2.Checked)
			{
				productType = 2;
				decimal currentPrice = this.goods_store_price.Value.ToDecimal2();
				decimal num3 = this.txtAuctionStartPrice.Value.ToDecimal2();
				productModels.CurrentPrice = currentPrice;
				productModels.ImcrementPrice = this.txtImcrementPrice.Value.ToDecimal2();
				productModels.AuctionStartPrice = num3;
				productModels.StandPrice = num3;
			}
			else
			{
				if (this.rdoProductType3.Checked)
				{
					productType = 3;
					productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
				}
				else
				{
					if (this.rdoProductType4.Checked)
					{
						productType = 4;
						productModels.CurrentPrice = this.goods_store_price.Value.ToDecimal2();
						productModels.StandPrice = this.txtPromotePrice.Value.ToDecimal2();
						dateTime = string.Concat(new string[]
						{
							this.BeginTimeDay.Value,
							" ",
							this.ddlBeginTimeHour.SelectedItem.Text,
							":",
							this.ddlBeginTimeMM.SelectedItem.Text,
							":00"
						}).ToDateTime(new DateTime[0]);
						endDate = string.Concat(new string[]
						{
							this.EndTimeDay.Value,
							" ",
							this.ddlEndTimeHour.SelectedItem.Text,
							":",
							this.ddlEndTimeMM.SelectedItem.Text,
							":00"
						}).ToDateTime(new DateTime[0]);
					}
					else
					{
						if (this.rdoProductType5.Checked)
						{
							productType = 5;
							if (!string.IsNullOrEmpty(this.txtNeedPresentExp.Value))
							{
								needPresentExp = this.txtNeedPresentExp.Value.ToInt32(new int[0]);
							}
							productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
						}
					}
				}
			}
		}
		if (this.productType_Edit_2.Visible)
		{
			string value5 = this.HiddenFieldProductType.Value;
			if (value5 != null)
			{
				if (!(value5 == "1"))
				{
					if (!(value5 == "2"))
					{
						if (!(value5 == "3"))
						{
							if (!(value5 == "4"))
							{
								if (value5 == "5")
								{
									productType = 5;
									productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
									if (!string.IsNullOrEmpty(this.txtNeedPresentExp.Value))
									{
										needPresentExp = this.txtNeedPresentExp.Value.ToInt32(new int[0]);
									}
								}
							}
							else
							{
								productType = 4;
								productModels.CurrentPrice = this.goods_store_price.Value.ToDecimal2();
								productModels.StandPrice = this.txtPromotePrice.Value.ToDecimal2();
								dateTime = string.Concat(new string[]
								{
									this.BeginTimeDay.Value,
									" ",
									this.ddlBeginTimeHour.SelectedItem.Text,
									":",
									this.ddlBeginTimeMM.SelectedItem.Text,
									":00"
								}).ToDateTime(new DateTime[0]);
								endDate = string.Concat(new string[]
								{
									this.EndTimeDay.Value,
									" ",
									this.ddlEndTimeHour.SelectedItem.Text,
									":",
									this.ddlEndTimeMM.SelectedItem.Text,
									":00"
								}).ToDateTime(new DateTime[0]);
							}
						}
						else
						{
							productType = 3;
							productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
						}
					}
					else
					{
						productType = 2;
						decimal currentPrice = this.goods_store_price.Value.ToDecimal2();
						decimal num3 = this.txtAuctionStartPrice.Value.ToDecimal2();
						productModels.CurrentPrice = currentPrice;
						productModels.ImcrementPrice = this.txtImcrementPrice.Value.ToDecimal2();
						productModels.AuctionStartPrice = num3;
						productModels.StandPrice = num3;
					}
				}
				else
				{
					productType = 1;
					productModels.StandPrice = this.goods_store_price.Value.ToDecimal2();
				}
			}
		}
		decimal num4 = this.CustomPrice.Value.ToDecimal2();
		productModels.CustomPrice = ((num4 == 0m) ? productModels.StandPrice.ToString2() : num4.ToString2());
		productModels.ProductType = productType;
		productModels.BeginDate = dateTime;
		productModels.EndDate = endDate;
		productModels.Stocks = this.goods_storage.Value.ToInt32(new int[0]);
		string obj = DateTime.Now.ToString();
		productModels.CreateTime = obj.ToDateTime(new DateTime[0]);
		string obj2 = DateTime.Now.ToString();
		productModels.UpdateTime = obj2.ToDateTime(new DateTime[0]);
		productModels.Keyword = this.seo_keywords.Value;
		productModels.Inputer = base.user.UserName;
		string province = "";
		if (this.ddlProvince.SelectedItem.Text != "请选择")
		{
			province = this.ddlProvince.GetSelectText(new string[0]);
		}
		productModels.Province = province;
		string city = base.Request["ddlCity"].IsNull(new object[0]);
		productModels.City = city;
		string area = base.Request["ddlArea"].IsNull(new object[0]);
		productModels.Area = area;
		int isElite = 0;
		if (this.rdo_commend.Checked)
		{
			isElite = 1;
		}
		productModels.IsElite = isElite;
		int deliverType = 0;
		if (this.whops_buyer.Checked)
		{
			if (this.isApplyPostage_true.Checked)
			{
				productModels.DeliverPayType = 1;
				deliverType = this.CheckBoxList_DeliverType.SelectedValue.ToInt32(new int[0]);
			}
		}
		else
		{
			productModels.DeliverPayType = 0;
		}
		productModels.DeliverType = deliverType;
		productModels.Description = this.seo_description.Value;
		string text5 = "";
		if (this.goods_lbl1.Value.Trim() != "")
		{
			text5 += this.goods_lbl1.Value.Trim();
		}
		if (this.goods_lbl2.Value.Trim() != "")
		{
			if (text5 != "")
			{
				text5 = text5 + "、" + this.goods_lbl2.Value.Trim();
			}
			else
			{
				text5 += this.goods_lbl2.Value.Trim();
			}
		}
		if (this.goods_lbl3.Value.Trim() != "")
		{
			if (text5 != "")
			{
				text5 = text5 + "、" + this.goods_lbl3.Value.Trim();
			}
			else
			{
				text5 += this.goods_lbl3.Value.Trim();
			}
		}
		if (this.goods_lbl4.Value.Trim() != "")
		{
			if (text5 != "")
			{
				text5 = text5 + "、" + this.goods_lbl4.Value.Trim();
			}
			else
			{
				text5 += this.goods_lbl4.Value.Trim();
			}
		}
		productModels.Goods_lbl = text5;
		if (!string.IsNullOrEmpty(this.txtAlarmNum.Value))
		{
			value3 = this.txtAlarmNum.Value.ToInt32(new int[0]);
		}
		productModels.AlarmNum = new int?(value3);
		productModels.NeedPresentExp = needPresentExp;
		productModels.IsDeleted = new int?(0);
		if (!string.IsNullOrEmpty(this.ddlCalculateUnit.SelectedValue.Trim()))
		{
			productModels.PUnit = this.ddlCalculateUnit.SelectedValue.Trim();
		}
		if (this.rdoProductStandard1.Checked)
		{
			productModels.ProductStandard = 1;
		}
		else
		{
			productModels.ProductStandard = 2;
		}
		productModels.goods_serial = this.goods_serial.Value;
		string value6 = this.HiddenField2.Value;
		string value7 = this.HiddenField3.Value;
		string value8 = this.HiddenField4.Value;
		string value9 = this.HiddenField5.Value;
		string teamName = "";
		int teamNum = 0;
		decimal teamPrice = 0m;
		decimal tempSubScriptionRate = 0m;
		int teamNumber = 0;
		decimal teamPrice2 = 0m;
		int teamNumber2 = 0;
		decimal teamPrice3 = 0m;
		int teamNumber3 = 0;
		decimal teamPrice4 = 0m;
		int teamNumber4 = 0;
		decimal teamPrice5 = 0m;
		int teamNumber5 = 0;
		if (productModels.EnableSingleSell == 0)
		{
			Shop_Class shop_Class = new Shop_Class(this.conn);
			shop_Class.UpdateItemCountByClassIDType(Text.ToInt32(this.Class_id), "addproduct");
		}
		CM_ProductsBll cM_ProductsBll = new CM_ProductsBll();
		int num5 = int.Parse(this.ViewState["HtmlTable"].ToString());
		string text6 = "";
		for (int i = 0; i < num5; i++)
		{
			if (base.Request.Form["TextBox_" + i] != null)
			{
				if (base.Request.Form["TextBox_" + i].ToString() != "")
				{
					string text7 = text6;
					text6 = string.Concat(new string[]
					{
						text7,
						"<strong>",
						base.Request.Form["HiddenField_" + i].ToString(),
						"</strong>",
						base.Request.Form["TextBox_" + i].ToString(),
						"|"
					});
				}
			}
			else
			{
				if (base.Request.Form["DropDownList_" + i] != null)
				{
					if (base.Request.Form["DropDownList_" + i].ToString() != "")
					{
						string text7 = text6;
						text6 = string.Concat(new string[]
						{
							text7,
							"<strong>",
							base.Request.Form["HiddenField_" + i].ToString(),
							"</strong>",
							base.Request.Form["DropDownList_" + i].ToString(),
							"|"
						});
					}
				}
			}
		}
		if (this.ViewState["cblChecked"] != null)
		{
			text6 += this.ViewState["cblChecked"].ToString();
		}
		productModels.Attributes = text6;
		if (this.Stamp == "add")
		{
			if (this.rdoProductType3.Checked)
			{
				teamNum = this.DropTeamNum.SelectedItem.Text.ToInt32(new int[0]);
				teamName = string.Concat(new string[]
				{
					this.TeamName1.Text,
					",",
					this.TeamName2.Text,
					",",
					this.TeamName3.Text,
					",",
					this.TeamName4.Text,
					",",
					this.TeamName5.Text
				});
				if (!string.IsNullOrEmpty(this.OrderMoneyPercent.Value))
				{
					tempSubScriptionRate = this.OrderMoneyPercent.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamNumber1.Value))
				{
					teamNumber = this.TeamNumber1.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber2.Value))
				{
					teamNumber2 = this.TeamNumber2.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber3.Value))
				{
					teamNumber3 = this.TeamNumber3.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber4.Value))
				{
					teamNumber4 = this.TeamNumber4.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber5.Value))
				{
					teamNumber5 = this.TeamNumber5.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamPrice1.Value))
				{
					teamPrice = this.TeamPrice1.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice2.Value))
				{
					teamPrice2 = this.TeamPrice2.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice3.Value))
				{
					teamPrice3 = this.TeamPrice3.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice4.Value))
				{
					teamPrice4 = this.TeamPrice4.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice5.Value))
				{
					teamPrice5 = this.TeamPrice5.Value.ToDecimal2();
				}
			}
			productModels.TeamName = teamName;
			productModels.TeamNum = teamNum;
			productModels.TempSubScriptionRate = tempSubScriptionRate;
			productModels.TeamNumber1 = teamNumber;
			productModels.TeamNumber2 = teamNumber2;
			productModels.TeamNumber3 = teamNumber3;
			productModels.TeamNumber4 = teamNumber4;
			productModels.TeamNumber5 = teamNumber5;
			productModels.TeamPrice1 = teamPrice;
			productModels.TeamPrice2 = teamPrice2;
			productModels.TeamPrice3 = teamPrice3;
			productModels.TeamPrice4 = teamPrice4;
			productModels.TeamPrice5 = teamPrice5;
			DataTable dataTable = this.conn.GetDataTable("select * from HL_User u inner join HL_Group g on u.GroupID=g.GroupID where UserID=" + base.user.UserID);
			productModels.IsApprove = 1;
			if (!string.IsNullOrEmpty(dataTable.Rows[0]["GroupPower"].ToString()))
			{
				string[] array = dataTable.Rows[0]["GroupPower"].ToString().Split(new string[]
				{
					","
				}, StringSplitOptions.None);
				for (int i = 0; i < array.Length; i++)
				{
					if (array[i].ToString() == "allowproduceApproval")
					{
						productModels.IsApprove = 0;
					}
				}
			}
			productModels.ClassID = this.T_class_id;
			object[] addProduct = cM_ProductsBll.GetAddProduct(productModels);
			if (addProduct != null)
			{
				this.ProductID = addProduct[1].ToInt32(new int[0]);
				bool flag2 = cM_ProductsBll.GetProductImg(this.ProductID, base.user.UserID, this.HiddenField1.Value, value6, value7, value8, value9);
				if (base.OwnerStockPower(base.user.UserID))
				{
					this.EditStockInfo(this.ProductID, productModels.Stocks, productModels.StandPrice, productModels.PUnit);
				}
				base.Response.Redirect("Sucess.aspx?productID=" + addProduct[1]);
			}
		}
		else
		{
			if (this.HiddenFieldProductType.Value == "3")
			{
				teamNum = this.DropTeamNum.SelectedItem.Text.ToInt32(new int[0]);
				teamName = string.Concat(new string[]
				{
					this.TeamName1.Text,
					",",
					this.TeamName2.Text,
					",",
					this.TeamName3.Text,
					",",
					this.TeamName4.Text,
					",",
					this.TeamName5.Text
				});
				if (!string.IsNullOrEmpty(this.OrderMoneyPercent.Value))
				{
					tempSubScriptionRate = this.OrderMoneyPercent.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamNumber1.Value))
				{
					teamNumber = this.TeamNumber1.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber2.Value))
				{
					teamNumber2 = this.TeamNumber2.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber3.Value))
				{
					teamNumber3 = this.TeamNumber3.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber4.Value))
				{
					teamNumber4 = this.TeamNumber4.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamNumber5.Value))
				{
					teamNumber5 = this.TeamNumber5.Value.ToInt32(new int[0]);
				}
				if (!string.IsNullOrEmpty(this.TeamPrice1.Value))
				{
					teamPrice = this.TeamPrice1.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice2.Value))
				{
					teamPrice2 = this.TeamPrice2.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice3.Value))
				{
					teamPrice3 = this.TeamPrice3.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice4.Value))
				{
					teamPrice4 = this.TeamPrice4.Value.ToDecimal2();
				}
				if (!string.IsNullOrEmpty(this.TeamPrice5.Value))
				{
					teamPrice5 = this.TeamPrice5.Value.ToDecimal2();
				}
			}
			productModels.TeamName = teamName;
			productModels.TeamNum = teamNum;
			productModels.TempSubScriptionRate = tempSubScriptionRate;
			productModels.TeamNumber1 = teamNumber;
			productModels.TeamNumber2 = teamNumber2;
			productModels.TeamNumber3 = teamNumber3;
			productModels.TeamNumber4 = teamNumber4;
			productModels.TeamNumber5 = teamNumber5;
			productModels.TeamPrice1 = teamPrice;
			productModels.TeamPrice2 = teamPrice2;
			productModels.TeamPrice3 = teamPrice3;
			productModels.TeamPrice4 = teamPrice4;
			productModels.TeamPrice5 = teamPrice5;
			productModels.ProductID = this.HiddenFieldProductID.Value.ToInt32(new int[0]);
			bool updateProduct = cM_ProductsBll.GetUpdateProduct(productModels);
			if (updateProduct)
			{
				if (!string.IsNullOrEmpty(this.HiddenFieldImgID.Value))
				{
					bool flag2 = cM_ProductsBll.GetUpadateProductImg(Convert.ToInt32(this.HiddenFieldImgID.Value), this.HiddenField1.Value, value6, value7, value8, value9);
				}
				if (base.OwnerStockPower(base.user.UserID))
				{
					this.EditStockInfo(this.ProductID, productModels.Stocks, productModels.StandPrice, productModels.PUnit);
				}
				base.Response.Redirect("ShowProduct.aspx?productID=" + this.HiddenFieldProductID.Value);
			}
		}
	}
	protected void Button_refresh_Click(object sender, EventArgs e)
	{
		this.BindDeliverType();
	}
	protected void Button_test_Click(object sender, EventArgs e)
	{
	}
	private int AddStockInfo(int s_productid, int s_count, decimal s_price, string s_unit)
	{
		int result = 0;
		HoWave.Data.Model.StockInfoOrder stockInfoOrder = new HoWave.Data.Model.StockInfoOrder();
		string text = "RK" + DateTime.Now.TimeString();
		stockInfoOrder.InfoNumber = text;
		stockInfoOrder.CreateDate = new DateTime?(DateTime.Now);
		stockInfoOrder.Remark = "商品库存初始";
		stockInfoOrder.StockOrderType = "inPurchase";
		stockInfoOrder.StockStatus = new int?(1);
		stockInfoOrder.StockDate = new DateTime?(DateTime.Now);
		stockInfoOrder.Inputer = base.user.UserName;
		stockInfoOrder.OwnerID = base.user.UserID;
		stockInfoOrder.TotalMoney = new decimal?(s_price * s_count);
		int num = BLLInstance.BllStockInfoOrder.Add(stockInfoOrder);
		if (num > 0)
		{
			result = this.AddStockItemModel(s_productid, s_count, s_price, s_unit, text, num);
		}
		return result;
	}
	private int AddStockItemModel(int s_productid, int s_count, decimal s_price, string s_unit, string infonumber, int InfoID)
	{
		int result = 0;
		if (InfoID > 0)
		{
			HoWave.Data.Model.StockItemOrder stockItemOrder = new HoWave.Data.Model.StockItemOrder();
			stockItemOrder.InfoOrderID = new int?(InfoID);
			stockItemOrder.InfoNumber = infonumber;
			stockItemOrder.ProductID = new int?(s_productid);
			stockItemOrder.StockCount = new int?(s_count);
			stockItemOrder.Price = new decimal?(s_price);
			stockItemOrder.Unit = s_unit;
			result = BLLInstance.BllStockItemOrder.Add(stockItemOrder);
		}
		return result;
	}
	private void EditStockInfo(int s_productid, int s_count, decimal s_price, string s_unit)
	{
		string strSQLWhere = string.Concat(new object[]
		{
			" where StockOrderType='inPurchase' and OwnerID=",
			base.user.UserID,
			" and ProductID=",
			s_productid
		});
		DataTable stockOrderInfoItemListBySqlWhere = BLLInstance.BllStockInfoOrder.GetStockOrderInfoItemListBySqlWhere(strSQLWhere);
		if (stockOrderInfoItemListBySqlWhere.Rows.Count > 0)
		{
			decimal value = s_price * s_count;
			for (int i = 0; i < stockOrderInfoItemListBySqlWhere.Rows.Count; i++)
			{
				DataRow dataRow = stockOrderInfoItemListBySqlWhere.Rows[i];
				int num = 0;
				int num2 = 0;
				string infonumber = "";
				if (stockOrderInfoItemListBySqlWhere.Columns.Contains("ProductID"))
				{
					if (dataRow["ProductID"] != DBNull.Value)
					{
						int num3 = dataRow["ProductID"].ToInt32(new int[0]);
					}
				}
				if (stockOrderInfoItemListBySqlWhere.Columns.Contains("InfoOrderID"))
				{
					if (dataRow["InfoOrderID"] != DBNull.Value)
					{
						num = dataRow["InfoOrderID"].ToInt32(new int[0]);
					}
				}
				if (stockOrderInfoItemListBySqlWhere.Columns.Contains("ItemOrderID"))
				{
					if (dataRow["ItemOrderID"] != DBNull.Value)
					{
						num2 = dataRow["ItemOrderID"].ToString().ToInt32(new int[0]);
					}
				}
				if (stockOrderInfoItemListBySqlWhere.Columns.Contains("InfoNumber"))
				{
					if (dataRow["InfoNumber"] != DBNull.Value)
					{
						infonumber = dataRow["InfoNumber"].ToString();
					}
				}
				if (num > 0)
				{
					HoWave.Data.Model.StockInfoOrder model = BLLInstance.BllStockInfoOrder.GetModel(num);
					if (model != null)
					{
						model.InfoOrderID = num;
						model.TotalMoney = new decimal?(value);
						model.UpdateDate = new DateTime?(DateTime.Now);
						bool flag = BLLInstance.BllStockInfoOrder.Update(model);
						if (flag)
						{
							if (num2 > 0)
							{
								HoWave.Data.Model.StockItemOrder model2 = BLLInstance.BllStockItemOrder.GetModel(num2);
								if (model2 != null)
								{
									model2.ItemOrderID = num2;
									model2.ProductID = new int?(s_productid);
									model2.StockCount = new int?(s_count);
									model2.Price = new decimal?(s_price);
									model2.Unit = s_unit;
									BLLInstance.BllStockItemOrder.Update(model2);
								}
								else
								{
									this.AddStockItemModel(s_productid, s_count, s_price, s_unit, infonumber, num);
								}
							}
						}
					}
					else
					{
						this.AddStockInfo(s_productid, s_count, s_price, s_unit);
					}
				}
			}
		}
		else
		{
			this.AddStockInfo(s_productid, s_count, s_price, s_unit);
		}
	}
}
